package javabase.reflect;

import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.List;
import java.util.Properties;

public class ReflectTest2 {
	
	public static void main(String[] args) {
		try (InputStream is = new FileInputStream("src\\main\\resources\\config.properties")){
			
			//只读 
			InputStream is1 = ReflectTest2.class.getClassLoader().getResourceAsStream("config.properties");
			
			// 相对路径
			InputStream is2 = ReflectTest2.class.getResourceAsStream("../../config.properties");
			
			Properties props = new Properties();
			props.load(is2);
			
			String className = props.getProperty("className");
			
			List list = (List) Class.forName(className).newInstance();
			
			list.add(1);
			System.out.println(list);
			
		} catch (IOException | InstantiationException | IllegalAccessException | ClassNotFoundException e) {
			e.printStackTrace();
		}
	}
	
}
